import request from "@/util/request";
import type {SocEvents,SocEventConditionsTypes,SocEventParticipants} from "@/api/social/event/type";
import type {PageType} from "@/api/type";

enum API{
    BASE_URL = "/social/event",
    EVENT_PAGE_URL= "/social/event/page",
    EVENT_CONDITION_TYPE_List_URL= "/social/event/condition/type/list",
    EVENT_CONDITION_TYPE_BASE_URL= "/social/event/condition/type",
    EVENT_MIEN_URL_BY_EVENT_ID= "/social/event/mien/eventId",
    EVENT_PARTICIPANT= "/social/event/participant",
    EVENT_PARTICIPANT_PAGE= "/social/event/participant/page",
}

export function reqGetEventById(eventId: string){
    return request<SocEvents>({
        url: API.BASE_URL+"/"+eventId,
        method: "get",
    });
}
export function reqAddEvent(event: SocEvents){
    return request<string>({
        url: API.BASE_URL,
        method: "post",
        data: event,
    });
}
export function reqUpdateEvent(event: SocEvents){
    return request<string>({
        url: API.BASE_URL,
        method: "put",
        data: event,
    });
}
export function reqDeleteEvent(eventId: string){
    return request<string>({
        url: API.BASE_URL+"/"+eventId,
        method: "delete",
    });
}
export function reqGetEventPage(query: any){
    return request<PageType<SocEvents>>({
        url: API.EVENT_PAGE_URL,
        method: "get",
        params: query,
    });
}
export function reqGetEventConditionTypeList(){
    return request<SocEventConditionsTypes[]>({
        url: API.EVENT_CONDITION_TYPE_List_URL,
        method: "get",
    });
}
export function reqDelEventConditionType(conditionId: string){
    return request<SocEventConditionsTypes[]>({
        url: API.EVENT_CONDITION_TYPE_BASE_URL+"/"+conditionId,
        method: "delete",
    });
}
export function reqGetEventConditionTypeById(conditionTypeId: string){
    return request<SocEventConditionsTypes>({
        url: API.EVENT_CONDITION_TYPE_BASE_URL+"/"+conditionTypeId,
        method: "get",
    });
}
export function reqAddEventConditionType(data: SocEventConditionsTypes){
    return request({
        url: API.EVENT_CONDITION_TYPE_BASE_URL,
        method: "post",
        data
    });
}
export function reqUpdateEventConditionType(data: SocEventConditionsTypes){
    return request({
        url: API.EVENT_CONDITION_TYPE_BASE_URL,
        method: "put",
        data
    });
}

export function reqGetEventMienList(eventId: string){
    return request({
        url: API.EVENT_MIEN_URL_BY_EVENT_ID+"/"+eventId,
        method: "get",
    });
}
export function reqAddEventParticipant(data: SocEventParticipants){
    return request({
        url: API.EVENT_PARTICIPANT,
        method: "post",
        data
    });
}
export function reqGetEventParticipantPage(query: any){
    return request<PageType<SocEventParticipants>>({
        url: API.EVENT_PARTICIPANT_PAGE,
        method: "get",
        params: query,
    });
}
export function reqUpdateEventParticipant(data: SocEventParticipants){
    return request({
        url: API.EVENT_PARTICIPANT,
        method: "put",
        data
    });
}
export function reqDelEventParticipant(participantId: string){
    return request({
        url: API.EVENT_PARTICIPANT+"/"+participantId,
        method: "delete",
    });
}
export function reqGetEventParticipantById(participantId: string){
    return request<SocEventParticipants>({
        url: API.EVENT_PARTICIPANT+"/"+participantId,
        method: "get",
    });
}
